<?php
// Admin page for lifeprice
  

require_once("./functions.php");
require_once("./database.php");

session_start();
if(!user_admin()){
  header('location: ./index.php');
  exit;
}

$admins = query_select("
  SELECT *
  FROM user
  WHERE isadmin = 1
");

$users = query_select("
  SELECT *
  FROM user
  WHERE isadmin = 0
");

?>

<?php require_once("./header.php"); ?>

<img src = "./layout/adminpanel.png"/>

<div id = "citybigbox" style="margin: 0px auto;">
				<div id = "citycurved"></div>
				<div id = "citybox">
<div id="admins" style="float: left; padding-right: 60px;">

Admins: 
<ul style="position: relative; left: 30px;">
<?php
  foreach($admins as $i){
    echo '<li>';
    echo $i['username'];
    if($i['id'] != $_SESSION['user']){
      echo ' <a href="admin/dochangeusertype.php?id=' . $i['id'] . '&new=user">Demote</a>';
    }
    else {
      echo ' (This is you!)';
    }
    echo '</li>';
  }
?>
</ul>
</div>

<div id="users" style="float: left; padding-left: 20px; border-left: solid 1px #6e9960;">
Users:
<ul style="position: relative; left: 30px;">
<?php
  foreach($users as $i){
    echo '<li>';
    echo $i['username'];
    echo ' <a href="admin/dochangeusertype.php?id=' . $i['id'] . '&new=admin">Promote</a>';
    echo ' <a href="admin/dodeleteuser.php?id=' . $i['id'] . '">Delete</a>';
    echo '</li>';
  }
?>
</ul>
</div>
<div class="clear"> <!-- keeps floats within parent container --></div>
</div>
 
</div>

<?php require_once("./footer.php"); ?>
